
<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>后台登录</title>
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
	<link rel="stylesheet" href="__PUBLIC__/admin/css/xadmin.css">
    <link href="__PUBLIC__/css/layui.css" rel="stylesheet" type="text/css" media="all"/>
    <script type="text/javascript" src="__PUBLIC__/layui.js"></script>

</head>
<body>
    <div class="login-logo"><h1>小尚服装后台管理系统</h1></div>
    <div class="login-box" style="text-align: center;width: 500px;height: 380px;">
        <form class="layui-form" method="post">
            <h3>登录你的帐号</h3>
            <label class="login-title" for="username">帐号</label>
            <div class="layui-form-item">
                <input type="text" name="username" lay-verify="required" placeholder="请输入你的帐号" style="padding: 8px;">
            </div>
            <label class="login-title" for="password">密码</label>
            <div class="layui-form-item">
                <input type="text" name="password" lay-verify="required" placeholder="请输入你的密码" style="padding: 8px;">
            </div>
            <div class="form-actions">
                <button class="btn btn-warning pull-right" lay-submit lay-filter="*">登录</button>    
            </div>
        </form>
    </div>
<script type="text/javascript">
    layui.use(['form','layedit'], function(){
      $ = layui.jquery;
      var layer = layui.layer
      ,layedit = layui.layedit
      ,form = layui.form();
      //layer.msg('Hello World');

    form.on('submit(*)', function(data){
        $.ajax({
            url: "{:U('admin/user/login')}",//请求地址
            type: "post",//请求方式
            dataType: "json",//返回数据类型
            data: data.field,//发送的参数
            })
            .done(function(response) {
                  if(response.error==0){
                     layer.msg(response.info ,{icon:5});

                  }else{
                     layer.msg(response.info ,{icon:6});
                     location.href = response.url;
                  }
              })
            .fail(function() {
                alert("ajxs交互失败");
            })  

          return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });  
    });
</script>
</body>
</html>